package com.bustle.product.dto.provider;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import com.bustle.commons.MapConverter;
import com.bustle.product.data.Provider;
import com.bustle.user.dto.address.DtoToAddressMapConverter;

@Local
public interface DtoToProviderMapConverter extends MapConverter<ProviderDto, Provider>
{
  @Stateless
  public class DefaultDtoToProviderMapConverter extends AbstractMapConverter<ProviderDto, Provider> implements DtoToProviderMapConverter
  {
    @Override
    public void doMapping(ProviderDto paramASource, Provider paramADestination)
    {
      paramADestination.setAddress(dtoToAddressConverter.map(paramASource.getAddress(), paramADestination.getAddress()));
      paramADestination.setDescription(paramASource.getDescription());
      paramADestination.setEmail(paramASource.getEmail());
      paramADestination.setIdProvider(paramASource.getIdProvider());
      paramADestination.setImage(paramASource.getImage());
      paramADestination.setMap(paramASource.getMap());
      paramADestination.setName(paramASource.getName());
      paramADestination.setPhoneNumber(paramASource.getPhoneNumber());
    }

    @Override
    protected Provider build()
    {
      return new Provider();
    }

    @EJB
    protected DtoToAddressMapConverter dtoToAddressConverter;
  }
}